package cn.xiaomubiao.oschine.activity;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.xiaomubiao.oschine.MainActivity;
import cn.xiaomubiao.oschine.R;

/**
 * Created by hasee on 2017/4/8.
 */

public class SpeashActivity extends AppCompatActivity {
    @BindView(R.id.iv_welcome)
    ImageView mIvWelcome;

    @Override
    protected void onCreate( @Nullable Bundle savedInstanceState ) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_speash);
        ButterKnife.bind(this);

       /* ObjectAnimator animator = ObjectAnimator.ofFloat(mIvWelcome,"alpha",0.2f,1.0f);
        animator.setDuration(5000);
        animator.start();

        animator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart( Animator animation ) {

            }

            @Override
            public void onAnimationEnd( Animator animation ) {
                Intent intent = new Intent(SpeashActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationCancel( Animator animation ) {

            }

            @Override
            public void onAnimationRepeat( Animator animation ) {

            }
        });*/

        AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f,1f);
        alphaAnimation.setDuration(2000);
        alphaAnimation.setFillAfter(true);
        mIvWelcome.setAnimation(alphaAnimation);
//        mIvWelcome.startAnimation(alphaAnimation);
        alphaAnimation.start();
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart( Animation animation ) {

            }

            @Override
            public void onAnimationEnd( Animation animation ) {
                Intent intent = new Intent(SpeashActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationRepeat( Animation animation ) {

            }
        });
    }
}
